/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.com.ufc.view;

import java.awt.BorderLayout;
import java.awt.Container;
import java.awt.FlowLayout;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;

import javax.swing.JDesktopPane;
import javax.swing.JFrame;
import javax.swing.JInternalFrame;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
  
public class DesktopTest extends JFrame {   
    public DesktopTest() {   
        super("Usando o JDesktop Pane");   
        JMenuBar bar = new JMenuBar();   
        JMenu addMenu = new JMenu("Adicionar");   
        JMenuItem newFrame = new JMenuItem("Frames Internos");   
        JPanel a = new JPanel();  
        addMenu.add(newFrame);   
        bar.add(addMenu);  
        a.setLayout(new FlowLayout());   
        getContentPane().add(a);   
        addMenu.add(newFrame);  
        setJMenuBar(bar);  
          
          
        final JDesktopPane desktop = new JDesktopPane();   
        this.setContentPane(desktop);   
           
          
        newFrame.addActionListener (new ActionListener() {   
            public void actionPerformed (ActionEvent e) {   
                JInternalFrame frame = new JInternalFrame("Frame Interno", true, true, true, true);   
                Container c = frame.getContentPane();   
                JPanel panel = new JPanel();   
                c.add(panel, BorderLayout.CENTER);   
                frame.setSize(200,250);   
                frame.setOpaque(true);  
                frame.show();  
                desktop.add(frame);   
                  
            }   
            }   
            );   
        setSize(500,400);   
        show();   
}   
  
public static void main(String args[]) {   
    DesktopTest a = new DesktopTest();   
    a.addWindowListener(new WindowAdapter() {   
        public void windowClosing(WindowEvent e) {   
            System.exit(0);   
        }   
        }   
        );  
}   
}   